package cn.lh.service.impl;

import cn.hutool.core.collection.CollUtil;
import cn.lh.dao.ProductDao;
import cn.lh.entity.dto.ProductDto;
import cn.lh.entity.req.ProductReq;
import cn.lh.entity.vo.ProductVo;
import cn.lh.service.ProductService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 产品表 服务实现类
 * </p>
 *
 * @author linhong
 * @since 2025-04-14
 */
@Service
public class ProductServiceImpl extends ServiceImpl<ProductDao, ProductDto> implements ProductService {

    @Resource
    private ProductDao productDao;

    @Override
    public void saveOrUpdate(ProductReq req) {
        ProductDto dto = new ProductDto();
        dto.setName(req.getProductName());
        dto.setId(req.getProductId());
        dto.setTypeId(req.getProductTypeId());
        this.saveOrUpdate(dto);
    }

    @Override
    public List<ProductVo> getList(String productName,Integer productTypeId) {
        return productDao.getList(productName,productTypeId);
    }
}
